package com.gluck.cases.boostrap.config;

import com.gluck.cases.boostrap.filter.ExceptionFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @ClassName FilterRegistrationBean
 * @Desc TODO
 * @Author I am Gluck
 * @Date 2022/5/18 - 5:08 下午
 **/
@Configuration
public class FilterConfig {

    @Autowired
    private ExceptionFilter exceptionFilter;


    @Bean
    public FilterRegistrationBean exceptionFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(exceptionFilter);
        registration.setName("exceptionFilter");
        registration.addUrlPatterns("/*");
        //此处尽量小，要比其他Filter靠前
        registration.setOrder(-1);
        return registration;
    }
}
